package com.four.collage.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.four.collage.entity.Groupgoods;
import com.four.collage.entity.Groupmanage;
import com.four.collage.feign.UserFeginservice;
import com.four.collage.service.IGroupmanageService;
import com.four.collage.vo.GoodsAndAttrVo;
import com.four.collage.vo.GroupManageVo;
import com.guli.common.utils.R;
import com.guli.common.vo.CityVo;
import com.guli.common.vo.UserabdcityVo;
import org.bouncycastle.crypto.tls.CipherType;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.function.ObjDoubleConsumer;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gs
 * @since 2021-12-18
 */
@RestController
@RequestMapping("/groupmanage")
public class GroupmanageController {

    @Autowired
    private IGroupmanageService groupmanageService;

    @Autowired
    private UserFeginservice userFeginservice;


    /**
     * 拼团管理列表、分页、模糊
     *
     * @param vo
     * @param page
     * @param size
     * @return
     */
    @PostMapping("/list")
    public IPage<Groupmanage> list(@RequestBody GroupManageVo vo,
                                  @RequestParam(value = "page",defaultValue = "1")Integer page,
                                  @RequestParam(value = "size",defaultValue = "3")Integer size){

        return groupmanageService.groupManageList(vo,page,size);
    }

    /**
     * 用户点击开团
     * 添加到拼团管理
     * @param grId
     * @return
     */
    @PostMapping("/addGroupmanage/{grId}/{loginName}")
    public R addGroupmanage(@PathVariable("grId")Integer grId,@PathVariable("loginName")String loginName){
        groupmanageService.addGroupmanage(grId,loginName);
        return R.ok();
    }

    /**
     * 立即拼团
     * @param groId
     * @param loginName
     * @return
     */
    @PutMapping("updGroupmanageNum/{groId}/{loginName}")
    public R updGroupmanageNum(@PathVariable("groId")Integer groId,@PathVariable("loginName")String loginName){
        groupmanageService.updGroupmanageNum(groId,loginName);
        return R.ok();
    }

    /**
     * 添加用户的地址
     * @param userabdcityVo
     * @return
     */
    @PostMapping("/toaddUderCity")
    public R toaddUderCity(@RequestBody UserabdcityVo userabdcityVo){
        userFeginservice.addUserandcity(userabdcityVo);
        return R.ok();
    }
}
